package com.spring.lth.controller;

import com.spring.lth.domain.Card;
import com.spring.lth.server.ICardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 罗天豪
 * @date 2019/7/26
 */
@RestController
public class CardController {

    @Autowired
    private ICardService service;

    @GetMapping("/card/{id}")
    public Card getCardById(@PathVariable Long id){
        Card cardById = service.getCardById(id);
        return cardById;
    }

    @PostMapping("/card")
    public Card saveCard(@RequestBody Card card) {
        Card card1 = service.saveCard(card);
        return card1;
    }

    @DeleteMapping("/card")
    public Card removeCard(@RequestBody Card card) {
        Card card1 = service.removeCard(card);
        return card1;
    }
}
